package com.loveprogrammer.eternity.model.effect;

import com.loveprogrammer.eternity.action.BaseAction;
import com.loveprogrammer.eternity.enums.EffectTimeEnum;
import com.loveprogrammer.eternity.model.Character;
import com.loveprogrammer.eternity.model.attack.AttackEntity;
import com.loveprogrammer.eternity.model.attack.AttackResult;

import java.io.Serializable;
import java.util.List;

/**
 * @version 1.0.0
 * @description:
 * @author: eric
 * @date: 2023-02-15 16:07
 **/
public abstract class AbstractEffect extends BaseAction implements Effect, Serializable {

    private String id;

    private Integer templateId;

    public AbstractEffect(String id) {
        this.id = id;
    }

    @Override
    public StringBuilder update(Character attack, EffectTimeEnum effectTimeEnum,
                         AttackResult entity,
                         List<? extends Character> attackList, Character... defence) {

        if(trigger(effectTimeEnum)) {
            // eventManager.notifyMessage("触发",1);
            return doUpdate(attack, entity, attackList, defence);
        }else{
            return new StringBuilder();
        }
    }

    protected abstract StringBuilder doUpdate(Character attack, AttackResult entity, List<? extends Character> attackList, Character[] defence);

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }
}
